#!/usr/bin/env python

import os
from urllib2 import Request, urlopen, URLError, HTTPError

def save_file(url, filename=None):
    if filename is None:
        #Use filename from url
        filename = os.path.basename(url)

    #download
    print 'Getting %s from %s' % (filename, url)
    stream = urlopen(url)
    output = open(filename, 'w')
    output.write(stream.read())


def main():
    base_url = 'http://www.gpweek.com/PDF/GP0%02d.pdf'
    for i in range(2, 33):
        save_file(base_url % i)

if __name__ == '__main__':
    main()
